--[[
-- * 我的恢复效果分摊给 buff来源 (这个buff是在敌人身上)]]

---@class BuffEffect374100000 : BaseBuffEffect
BuffEffect374100000 = ClientFight.CreateClass("BuffEffect374100000", ClientFight.BaseBuffEffect)
local t = BuffEffect374100000

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};
    --fighter, skill, result, false 被伤害前触发
    if (table.getn(parameters) < 3) then
        return IBuffEffect.FAIL;
    end
    if not parameters[3] then
        return IBuffEffect.FAIL;
    end
    local result = parameters[3];

    if result.state ~= DamageResultTypeEnum.HEAL then
        return IBuffEffect.FAIL;
    end
    local buffEffectValue = buff.buffBean.f_BuffEffectValue;
    local addHp = (Utils.toRatio(buffEffectValue[1]) * result.damage);
    if (addHp < 1) then
        return IBuffEffect.FAIL;
    end
    local oldDamage = result.damage;
    result.damage = result.damage - addHp;
    DamageManager.setFighterHp(fight, buff.source, buff.target, nil, DamageResultTypeEnum.HEAL,
            addHp, buff.source.hp + addHp, true, false, true);
    SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff:"
            .. buff.modelId .. " 触发分摊治疗给: " .. buff.source.fighterId .. " 分摊量: " .. addHp .. "  原治疗量: " .. oldDamage);
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()